<!-- 这是什么页面 -->
<template>
	<view class="content">
		<view class="search-box">
			<view class="search-box">
				<view class="search-left-box">
					<uni-search-bar @confirm="search" v-model="searchValue" @cancel="cancel" @clear="clear"
						placeholder="请输入批次名称">
					</uni-search-bar>
				</view>
				<view class="search-right-box">
					中标时间：<uni-datetime-picker returnType="timestamp" type="date" v-model="fahuoDate1" @change="changeLog1" />
				</view>
			</view>
		</view>
		<z-paging ref="paging" v-model="dataList" :default-page-size="row" @onRefresh="onRefresh" @query="getList"
			auto-show-system-loading auto-show-back-to-top>
			<view class="" style="margin-top: 140rpx;"></view>
			<view class="list-box" @click="goto(item.id)" v-for="(item,index) in dataList" :key="index">
				<view class="top-box">
					<view class="tiem-box" v-if="item.area">
						省份地区：{{item.area}}
					</view>
					<view class="status-box">
					<!-- <view class="item-box">
						
					</view> -->
				</view>
				</view>
				<view class="xian"></view>
				<view class="title-box" v-if="item.name">
					批次名称：{{item.name}}
				</view>
				<view class="title-box" v-if="item.biaobao">
					购买标包：{{item.biaobao}}
				</view>
				<view class="title-box" v-if="item.other" style="color: blue;">
					特殊要求或不满足记录：{{item.other}}
				</view>
				<view class="info-box">
					<view class="info-item" v-if="item.openDate">
						<view class="info-item-title">
							开标时间
						</view>
						<view class="info-item-text">
							{{item.openDate}}
						</view>
					</view>
					<view class="info-item" v-if="item.winDate">
						<view class="info-item-title">
							中标时间
						</view>
						<view class="info-item-text">
							{{item.winDate}}
						</view>
					</view>
					<view class="info-item" v-if="item.bond">
						<view class="info-item-title">
							保证金金额(万元)
						</view>
						<view class="info-item-text">
							{{item.bond}}
						</view>
					</view>
					<view class="info-item" v-if="item.winMoney">
						<view class="info-item-title">
							中标金额(万元)
						</view>
						<view class="info-item-text">
							{{item.winMoney}}
						</view>
					</view>
					<view class="info-item" v-if="item.winType">
						<view class="info-item-title">
							中标类别
						</view>
						<view class="info-item-text">
							{{item.winType}}
						</view>
					</view>
					<view class="info-item" v-if="item.winService">
						<view class="info-item-title">
							中标服务费(万元)
						</view>
						<view class="info-item-text">
							{{item.winService}}
						</view>
					</view>
					<view class="info-item" v-if="item.serviceStatus">
						<view class="info-item-title">
							中标服务费状态
						</view>
						<view class="info-item-text">
							{{item.serviceStatus}}
						</view>
					</view>
				</view>
				<view class="text-box" v-if="item.remark">
					备注：{{item.remark}}
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	import OrdrList from '@/components/ordrList/index.vue'
	import * as index from '@/api/index.js'
	export default {
		components: {
			OrdrList
		},
		data() {
			return {
				row: 10, // 一页10条数据
				searchValue: '', // 搜索绑定值
				searchValue1: '', // 第二个搜索绑定值
				dataList: [], // 列表数据
				please_buy_source: [],
				please_buy_status: [],
				fahuoDate:'',
				fahuoDate1:'',
			}
		},
		onLoad() {
			this.dictType() // 数据字典查询

		},
		onShow() {

		},
		methods: {
			reload() {
				console.log('重新加载');
				this.$nextTick(() => {
					this.$refs.paging.reload()
				})
			},

			goto(e) {
				uni.navigateTo({
					url:'/pagesA/orderAdmin/procurementAudit/commodity/index?id=' + e
				})
			},
			dictType() {
				index.typesBatch({
					'please_buy_source' : 'please_buy_source',
					'please_buy_status' : 'please_buy_status'
				}).then(res => {
					this.please_buy_source = res.data.please_buy_source
					this.please_buy_status = res.data.please_buy_status
				})
			},
			// 当页面滚动到底部事件被触发
			onReachBottom() {
				// 通知z-paging滚动到底部了，z-paging会进行相应的处理，例如加载更多数据
				this.$refs.paging.pageReachBottom();
			},
			// 下拉刷新被触发
			onRefresh() {
				// 告知z-paging下拉刷新结束，这样才可以开始下一次的下拉刷新
				setTimeout(() => {
					this.$tools.toast('刷新成功～')
				}, 500)
			},
			// @query所绑定的方法不要自己调用！！需要刷新列表数据时，只需要调用this.$refs.paging.reload()即可
			getList(pageNum, pageSize) {
				index.lnZhaobiaolistZb({
					pageNum,
					pageSize,
					name:this.searchValue,
					openDate: this.fahuoDate,
					winDate: this.fahuoDate1,
					orderByColumn: 'open_date',
					isAsc: 'desc'
				}).then(res=>{
					this.$refs.paging.complete(res.rows);
				})
			},
			// 搜索条件 清除 查询
			search(res) {
				this.$refs.paging.reload()
			},
			clear(res) {
				this.searchValue = ''
				this.$refs.paging.reload()
			},
			cancel() {
				this.searchValue = ''
				this.$refs.paging.reload()
			},
			clear1(res) {
				this.searchValue1 = ''
				this.$refs.paging.reload()
			},
			cancel1(res) {
				this.searchValue1 = ''
				this.$refs.paging.reload()
			},
			changeLog(e) {
				console.log('change事件:', e);
				let date = new Date(e);
				let year = date.getFullYear();
				// 在日期格式中，月份是从0开始的，因此要加0，使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
				let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
				let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
				let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				// 拼接
				// return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
				this.fahuoDate =  year + "-" + month + "-" + day;
				this.$refs.paging.reload()
			},
			changeLog1(e) {
				console.log('change事件:', e);
				let date = new Date(e);
				let year = date.getFullYear();
				// 在日期格式中，月份是从0开始的，因此要加0，使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
				let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
				let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
				let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				// 拼接
				// return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
				this.fahuoDate1 =  year + "-" + month + "-" + day;
				this.$refs.paging.reload()
			},
		}
	}
</script>

<style scoped lang="scss">
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding-left: 20rpx;
		padding-right: 20rpx;
	
		.table-box {
			width: 750rpx;
			position: sticky;
			top: 0;
			z-index: 2;
			background: #ffffff;
			display: flex;
			justify-content: space-around;
	
			.table {
				padding: 23rpx 0;
				font-size: 28rpx;
				font-weight: 400;
				color: #666666;
				display: flex;
				flex-direction: column;
				align-items: center;
	
				.border {
					margin-top: 10rpx;
					width: 32rpx;
					height: 4rpx;
				}
			}
	
			.tableChange {
				padding: 23rpx 0;
				font-size: 28rpx;
				font-weight: 400;
				color: #333333;
				display: flex;
				flex-direction: column;
				align-items: center;
	
				.border {
					margin-top: 10rpx;
					width: 32rpx;
					height: 4rpx;
					background: #8295BC;
				}
			}
		}
	
		.search-box {
			width: 750rpx;
			height: 123rpx;
			background: #FFFFFF;
			z-index: 99;
			display: flex;
			align-items: center;
			.search-left-box {
				width: 45%;
			}
			.search-right-box {
				margin-left: 10%;
				width: 45%;
			}
		}
	
		.list-box {
			padding-left: 20rpx;
			padding-right: 20rpx;
			margin-top: 30rpx;
			border-radius: 8rpx;
			background: #FFF;
		
			.top-box {
				display: flex;
				align-items: center;
				padding: 20rpx 0rpx;
		
				.tiem-box {
					color: #999;
					font-size: 24rpx;
				}
		
				.status-box {
					margin-left: auto;
					display: flex;
					align-items: center;
		
					.item-box {
						padding: 4rpx 12rpx;
						height: 42rpx;
						border-radius: 10rpx;
						background: #F5F7FB;
						color: #8295BC;
						font-size: 24rpx;
					}
				}
			}
		
			.xian {
				width: 662rpx;
				border-bottom: 1px solid #EAEAEA;
			}
		
			.title-box {
				padding-top: 10rpx;
				padding-bottom: 10rpx;
				color: #333;
				font-size: 28rpx;
				font-weight: bold;
			}
		
			.info-box {
				display: flex;
				flex-wrap: wrap;
				justify-content: space-between;
				border-radius: 8rpx;
				background: #F5F7FB;
				padding-top: 10rpx;
				padding-bottom: 10rpx;
		
				.info-item {
					flex: 0 0 calc(48% - 20rpx);
					margin-top: 20rpx;
					margin-bottom: 30rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
		
					.info-item-title {
						font-weight: bold;
						margin-bottom: 10rpx;
						color: #999;
						font-size: 24rpx;
					}
		
					.info-item-text {
						margin-top: 8rpx;
						color: #333;
						font-size: 28rpx;
						font-weight: bold;
					}
				}
			}
		
		
		
			.text-box {
				padding-top: 10rpx;
				padding-bottom: 10rpx;
				color: #999;
				font-size: 24rpx;
			}
		
			.bnt-box {
				padding-top: 20rpx;
				padding-bottom: 20rpx;
		
				.bnt-big-box {
					display: flex;
					justify-content: space-between;
					flex-wrap: wrap;
		
					.bnt {
						color: #4D8987;
						font-size: 24rpx;
						flex: 0 0 24%;
						height: 30px;
						display: flex;
						align-items: center;
						justify-content: center;
						border-radius: 10rpx;
						background: #F5F7FB;
						text-align: center;
						/* 边距懒得算，css函数代替 */
						margin-right: calc(4% / 3);
						margin-bottom: calc(4% / 3);
		
					}
		
					/* 去除每行尾的多余边距 */
					.bnt:nth-child(4n) {
						margin-right: 0;
					}
		
					/* 使最后一个元素的边距填满剩余空间 */
					.bnt:last-child {
						margin-right: auto;
					}
				}
			}
		}
	}
</style>